const apiConfig = {
    register: {
      url: 'http://192.168.1.111:8080/user/register',
      method: 'POST',
      header: {
        'Content-Type': 'application/json'
      }
    },
  
    login: {
      url: 'http://192.168.1.111:8080/user/login',
      method: 'POST',
      header: {
        'Content-Type': 'application/json'
      }
    },
  
    // 可以继续添加更多的 API 配置
  };
  
  module.exports = {
    request: function(apiName, data) {
      const config = apiConfig[apiName];
      if (!config) {
        return Promise.reject(new Error('API not found'));
      }
  
      return new Promise((resolve, reject) => {
        wx.request({
          ...config,
          data: data,
          success(res) {
            if (res.statusCode === 200) {
              resolve(res.data);
            } else {
              reject(new Error(res.data.message || `Request to ${apiName} failed`));
            }
          },
          fail(err) {
            reject(err);
          }
        });
      });
    }
  };
  
  
  